package com.xinzhi.controller;


import com.baomidou.mybatisplus.extension.api.R;
import com.xinzhi.service.IUserService;
import com.xinzhi.utils.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 *
 */
@RestController
public class IUserControllers {
    @Autowired
    private IUserService iuserService;

    /**
     * 根据手机号密码进行注册
     * @param phone
     * @param password
     * @param password2
     * @return
     */
    @GetMapping ("/register")
    public Result insert(@RequestParam("phone") String phone, @RequestParam("password") String password, @RequestParam("password2") String password2) {
        Result append = iuserService.append(phone, password, password2);
        return append;
    }

    /**
     * 根据手机号修改密码
     * @param phone    手机号
     * @param password  密码
     * @param password2  确认密码
     * @return
     */
    @GetMapping ("/update")
    public Result update(String phone,String password, String password2){
        Result update = iuserService.update(phone, password, password2);
        return update;
    }

    /**
     * 根据手机号查询用户id
     * @param phone
     * @return
     */
    @PostMapping("/selectid")
    public Result selectid(String phone){
    Result id = iuserService.selectUser(phone);
    return id;
}

    /**
     * 根据手机号查询用户信息
     * @param phone
     * @return
     */
    @RequestMapping("/sel")
    public Result selectUser(String phone){
    Result users = iuserService.selectUsers(phone);
    return users;
}
   @GetMapping("/updateHead")
    public Result updateHead(String headPhoto,String phone){
        return iuserService.updateHead(headPhoto,phone);
    }

}
